<template>
{{#if ctrl.psSysPFPlugin}}
  {{> @macro/plugins/widget/widget-use.hbs appPlugin=ctrl.psSysPFPlugin}}
{{else}}
  <AppExpBar :class="classNames" :id="controlID">
  {{#if ctrl.showTitleBar}}
    <template #titleBar>
      <div class="control-header__left__caption">
    {{#if ctrl.psSysImage}}
      {{#if ctrl.psSysImage.imagePath}}
        <img src="{{ctrl.psSysImage.imagePath}}"/>
      {{/if}}
      {{#if ctrl.psSysImage.cssClass}}
        <i class="{{ctrl.psSysImage.cssClass}}"></i>
      {{/if}}
    {{/if}}
        <span class="text">\{{$t(model.lanResTag, model.title)}}</span>
      </div>
  </template>
  {{/if}}
  {{#if ctrl.enableSearch}}
      <template #quickSearch>
        {{> @macro/common/quick-search.hbs placeholder="model.quickSearchPlaceholder"}}
      </template>
  {{/if}}
  {{#each ctrl.ctrls as | ctrl |}}
    {{#eq ctrl.controlType 'TOOLBAR'}}
      <template #toolbar>
        {{> @macro/widgets/toolbar/toolbar.hbs ctrl=ctrl}}
      </template>
    {{/eq}}
    {{#eq ctrl.controlType "TREEVIEW"}}
      <template #default>
        {{> @macro/widgets/tree-detail/tree.hbs ctrl=ctrl props=":selectFirstDefault='true'"}}
      </template>
    {{/eq}}
  {{/each}}
  </AppExpBar>
{{/if}}
</template>
<script setup lang="ts">
// 基于template/src/widgets/\{{appEntities}}/\{{ctrls@TREEEXPBAR}}-tree-exp-bar/\{{spinalCase ctrl.codeName}}-tree-exp-bar.vue.hbs生成
{{> @macro/plugins/widget/widget-import.hbs ctrl=ctrl}}
{{#each ctrl.ctrls as | ctrl |}}
    {{#eq controlType "TREEVIEW"}}
import {{ctrl.psAppDataEntity.codeName}}{{codeName}}Tree from '@widgets/{{spinalCase ctrl.psAppDataEntity.codeName}}/{{spinalCase codeName}}-tree/{{spinalCase codeName}}-tree.vue';
    {{/eq}}
{{/each}}
{{#hasCtrl ctrl.ctrls 'TOOLBAR'}}
import { AppToolbar } from '@components/widgets/toolbar';
{{/hasCtrl}}
import { AppExpBar } from '@components/widgets/exp-bar';
import { TreeExpBarActionType, TreeExpBarController, IContext, ITreeExpBarAbility, ITreeExpBarControllerParams, ITreeExpBarStore, IParam, ITreeExpBarController, ILoadingHelper, createUUID, IViewCtx } from '@/core';
import {
{{#hasCtrl ctrl.ctrls 'TOOLBAR'}}
  handleToolbarItemClick,
{{/hasCtrl}}
{{#if ctrl.enableSearch}}
  handleQuickSearch,
{{/if}}
  useNavParamsBind,
  useEventBind,
  getCtrlClassNames,
  handleCtrlInit,
  handleCtrlAction,
  handleCtrlDestroy
} from '@/hooks/use-ctrl';
import { model } from './{{spinalCase ctrl.codeName}}-tree-exp-bar-model';
{{> @macro/widgets/ctrl/ctrl-props.hbs
    props="openView?: Function;
    newView?: Function;
    "
}}

{{> @macro/common/emit.hbs name="ctrl" actionType="TreeExpBarActionType" ability="ITreeExpBarAbility"}}

const controlID = 'id' + createUUID(); 

const classNames = computed(() => {
    const classNames = getCtrlClassNames(model, props);
    Object.assign(classNames, {
        'app-control-expbar': true
    })
    return classNames;
});

// 树导航控制器
const params: ITreeExpBarControllerParams<TreeExpBarActionType, ITreeExpBarAbility> = {
    name: props.name,
    model,
    evt,
    controlID,
    openView: props.openView,
    newView: props.newView,
    closeView: props.closeView,
    pLoadingHelper: props.pLoadingHelper,
    pViewCtx: props.pViewCtx,
    handler: (data: ITreeExpBarStore) => { return reactive(data); }
};

{{> @macro/common/controller.hbs name="ctrl" IController="ITreeExpBarController" store="ITreeExpBarStore" ability="ITreeExpBarAbility" controller="TreeExpBarController"}}

</script>